﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Sites_Man_Root : System.Web.UI.MasterPage
{
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        if (!IsPostBack)
        {
            PageBase page = this.Page as PageBase;
            if (page != null)
            {
                dsFooter.SiteId = page.AcmsContext.SiteId;
                dsFooter.SiteVersion = page.AcmsContext.SiteVersion;
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ucLoggedIn.Visible = Page.Request.IsAuthenticated;
            ucLogin.Visible = !Page.Request.IsAuthenticated;
            var acmsPage = this.Page as Acms.AcmsControls.TemplatePage;
            if (acmsPage != null && acmsPage.AcmsContext != null)
            {
                imgHome.NavigateUrl = ResolveUrl(acmsPage.AcmsContext.GetUrl("~/default.aspx"));
            }
        }
    }

    protected void dsBreadcrumbs_SelectData(object sender, Acms.DataControls.SelectEventArgs<Acms.Bll.Post> e)
    {
        var acmsPage = this.Page as Acms.AcmsControls.TemplatePage;
        if (acmsPage != null && acmsPage.AcmsContext != null && acmsPage.AcmsContext.CurrentPost != null)
        {
            var data = new List<Acms.Bll.Post>();
            var current = acmsPage.AcmsContext.CurrentPost;
            while (current != null)
            {
                data.Insert(0, current);
                current = current.Parent;
            }
            e.SetData(data);
        }
    }
}
